/* 
 * File:   protothread.h
 * Author: root
 *
 * Created on March 12, 2012, 2:57 PM
 */

#ifndef LINUX_H
#define	LINUX_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "core/Const.h"
#include <stdio.h>
    
typedef struct {
    UInt16 Val;
    UInt16 Mod;
    BitField Enabled;
    BitField InterruptEnabled:1;
    BitField InterruptRunning:1;
}stTimer;

extern stTimer SysTimer;

void thread_timer_start(void);
void thread_timer_disable(void);
void thread_timer_enable(void);

#define DISABLE_INTERRUPT   SysTimer.InterruptEnabled = FALSE
#define ENABLE_INTERRUPT    SysTimer.InterruptEnabled = TRUE

#define LOCK_INTERRUPT      {int a = SysTimer.InterruptEnabled; DISABLE_INTERRUPT
#define UNLOCK_INTERRUPT    if (a > 0) {ENABLE_INTERRUPT;}}

#define RESET_WATCHDOG       

#define CORE_TIMER_VAL      SysTimer.Val
#define CORE_TIMER_MOD      SysTimer.Mod
#define CORE_TIMER_10MS     60
#define CORE_TIMER_START    thread_timer_start()
#define CORE_TIMER_STOP     thread_timer_stop()

#define _BYTE_ORDER_ _LITTLE_ENDIAN_
/**************************/

#define TIME_TICK   10        //ms
#define USE_ROM     NO
#define MAX_INPUT_NUM        4

#ifdef	__cplusplus
}
#endif

#endif	/* LINUX_H */

